package com.xinglai.yun;

import android.content.Context;
import android.support.multidex.MultiDex;

import com.action.ioc.component.DaggerAppComponent;
import com.action.ioc.module.HttpSupperApiModule;
import com.action.ui.activity.XYBMainActiviy;
import com.base.app_core.App;
import com.base.app_core.ioc.module.AppModule;
import com.golden.rice.InitConfiguration;
import com.golden.rice.manager.AdViewBannerManager;
import com.golden.rice.manager.AdViewNativeManager;
import com.golden.rice.manager.AdViewSpreadManager;
import com.hubcloud.adhubsdk.AdHub;


/**
 * Created by jiansheng.li on 2018/3/17.
 */

public class Application extends App {

    public static AdViewSpreadManager adViewSpreadManager;
    public static AdViewNativeManager adViewNativeManager;
    public static AdViewBannerManager adViewBannerManager;
    private InitConfiguration build;

    @Override
    public void onCreate() {
        super.onCreate();
        adViewSpreadManager = AdViewSpreadManager.getInstance(this);
        adViewNativeManager = AdViewNativeManager.getInstance(this);
        adViewBannerManager = AdViewBannerManager.getInstance(this);
        AdHub.initialize(this, "2195");
    }

    @Override
    public String getServerUrl() {
        return BuildConfig.SERVER_URL;
    }


    @Override
    public String getWxAppID() {
        return BuildConfig.WEIXIN_APPID;
    }

    @Override
    public void setupAppConment() {
        appComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).httpSupperApiModule(new HttpSupperApiModule()).build();
    }

    @Override
    public String getBugLyID() {
        return BuildConfig.BUGLY_APPID;
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }

    public InitConfiguration getAdViewInit() {
        if (build == null) {
            build = new InitConfiguration.Builder(this)
                    .setUpdateMode(InitConfiguration.UpdateMode.EVERYTIME) // 实时获取配置，非必须写
//                    .setBannerCloseble(InitConfiguration.BannerSwitcher.DEFAULT)
//                    .setAdSize(InitConfiguration.AdSize.BANNER_AUTO_FILL)
//                    .setRunMode(BuildConfig.DEBUG ? InitConfiguration.RunMode.TEST : InitConfiguration.RunMode.NORMAL) //测试模式时log更多，方便调试，不影响竞价展示正式
                    .setYoumiIntent(XYBMainActiviy.class)
                    .setAdYoumiSize(InitConfiguration.AdYoumiSize.FIT_SCREEN)
                    .build();
        }
        return build;
    }

    public static AdViewBannerManager getAdViewBannerManager() {
        return adViewBannerManager;
    }

    public static AdViewNativeManager getAdViewNativeManager() {
        return adViewNativeManager;
    }

    public static AdViewSpreadManager getAdViewSpreadManager() {
        return adViewSpreadManager;
    }
}
